#ifndef DATAPACKET_H
#define DATAPACKET_H

#include <QString>
#include <QByteArray>
#include <QDebug>
//#include "communcationhandler.h"
//#include "gpshandler.h"

class DataPacket
{
    enum { SIZEOF_HDR = 1, SIZEOF_GPSDATA = 17, SIZEOF_IMGDATA = 0};    // GPSDATA and IMGDATA size excludes header!

private:
    long datalength;
    QByteArray data;
    QByteArray gpsuavheader;
    QByteArray gpscarheader;
    QByteArray imgheader;
    QByteArray cmdheader;
    static const int GPSUAVLENGTH = 18;
    static const int GPSCARLENGTH = 12; // latitude, longitude, velocity

    int cmdcode;    // command code specifies hover (0), search/track (31), return to base (227), fly to point (252)
    float flytolat;
    float flytolng;

public:
    DataPacket(QByteArray obtdata);
    QByteArray getData();
    void encapsulate(QString type);
    void decapsulate();
    void packGPS();
    void unpackGPS();
    void packImage();
    void unpackCommand();
    int getCmd();
    float getFlyToLat();
    float getFlyToLng();
};

#endif // DATAPACKET_H
